<template>
  <section id="hero" class="hero section">
    <div class="hero-content">
      <div class="hero-text slide-in-left">
        <p class="hero-greeting">你好，我是</p>
        <h1 class="hero-name">
          <span class="glow-text">张三</span>
        </h1>
        <h2 class="hero-title">
          <span>{{ displayedText }}</span>
          <span class="cursor"></span>
        </h2>
        <p class="hero-description">
          热衷于创造优雅、高效的数字化解决方案<br>
          专注于前端开发与用户体验设计
        </p>
        <div class="hero-buttons">
          <button class="btn" @click="downloadResume">
            <span>下载简历</span>
          </button>
          <button class="btn" @click="scrollToContact">
            <span>联系我</span>
          </button>
        </div>
        <div class="social-links">
          <a href="https://github.com" target="_blank" class="social-link">
            <span>GitHub</span>
          </a>
          <a href="https://linkedin.com" target="_blank" class="social-link">
            <span>LinkedIn</span>
          </a>
          <a href="#" target="_blank" class="social-link">
            <span>Blog</span>
          </a>
        </div>
      </div>
      <div class="hero-image slide-in-right">
        <div class="avatar-container">
          <div class="avatar-glow"></div>
          <div class="avatar">
            <div class="avatar-border">
              <div class="avatar-inner">
                <span class="avatar-initials">ZS</span>
              </div>
            </div>
          </div>
        </div>
        <div class="code-window terminal">
          <div class="code-header">
            <span>~/portfolio/code.js</span>
          </div>
          <pre><code><span class="code-keyword">const</span> <span class="code-variable">developer</span> = {
  <span class="code-property">name</span>: <span class="code-string">'张三'</span>,
  <span class="code-property">role</span>: <span class="code-string">'前端工程师'</span>,
  <span class="code-property">skills</span>: [<span class="code-string">'Vue'</span>, <span class="code-string">'React'</span>, <span class="code-string">'TypeScript'</span>],
  <span class="code-property">isAvailable</span>: <span class="code-keyword">true</span>
};</code></pre>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const displayedText = ref('')
const fullText = '前端开发工程师 | Vue.js 专家'

const typeText = () => {
  let index = 0
  const timer = setInterval(() => {
    if (index <= fullText.length) {
      displayedText.value = fullText.slice(0, index)
      index++
    } else {
      clearInterval(timer)
    }
  }, 100)
}

const downloadResume = () => {
  console.log('下载简历')
}

const scrollToContact = () => {
  document.getElementById('contact').scrollIntoView({ behavior: 'smooth' })
}

onMounted(() => {
  typeText()
})
</script>

<style scoped>
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  padding: 0;
  box-sizing: border-box;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(0, 217, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 0, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.hero-content {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 4rem;
  align-items: center;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

.hero-content > * {
  box-sizing: border-box;
}

@media (min-width: 1600px) {
  .hero-content {
    gap: 5rem;
  }
}

.hero-greeting {
  color: var(--text-secondary);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.hero-name {
  font-size: 4.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.hero-title {
  font-size: 2rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  min-height: 2.5rem;
}

.hero-description {
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1.8;
  margin-bottom: 2.5rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 3rem;
}

.social-links {
  display: flex;
  gap: 2rem;
}

.social-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.3s;
  position: relative;
}

.social-link::before {
  content: '>';
  color: var(--accent-blue);
  margin-right: 0.5rem;
}

.social-link:hover {
  color: var(--accent-blue);
  transform: translateX(5px);
}

.hero-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

.avatar-container {
  position: relative;
}

.avatar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

.avatar {
  position: relative;
  z-index: 1;
}

.avatar-border {
  width: 180px;
  height: 180px;
  border: 3px solid var(--accent-blue);
  border-radius: 50%;
  padding: 5px;
  animation: rotate 10s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.avatar-inner {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.code-window {
  width: 100%;
  max-width: 500px;
  min-width: 350px;
  animation: fadeIn 1s ease-in 0.5s both;
  padding: 1rem;
  box-sizing: border-box;
  overflow: hidden;
  margin: 0 auto;
}

.code-header {
  color: var(--accent-purple);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.code-keyword {
  color: var(--accent-purple);
}

.code-variable {
  color: var(--accent-blue);
}

.code-property {
  color: var(--accent-cyan);
}

.code-string {
  color: #00ff00;
}

@media (max-width: 768px) {
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 0 1rem;
  }

  .hero-name {
    font-size: 2.5rem;
  }

  .hero-title {
    font-size: 1.3rem;
  }

  .hero-buttons {
    justify-content: center;
  }

  .social-links {
    justify-content: center;
  }
  
  .code-window {
    max-width: 100%;
    min-width: 280px;
    padding: 0.8rem;
    margin: 0 auto;
  }
  
  .hero-image {
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
  }
}
</style>
